﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HustQQModel;
using HustQQInterface;
using HustQQClient.MsgDispatcher;
using HustQQClient.UI;
using System.Windows.Forms;
using System.Drawing;
using System.Reflection;

namespace HustQQClient
{
    public class InfoControl
    {
        public static User CurrentUser = new User();

        //id, singleChat
        public static Dictionary<string, SingleChat> dictSingleChat 
            = new Dictionary<string, SingleChat>();
        //id, teamChat
        public static Dictionary<string, TeamChat> dictTeamChat
            = new Dictionary<string, TeamChat>();
        
        static bool IsDisposeOrNull(Control o)
        {
            if (o == null || o.IsDisposed)
            {
                return true;
            }
            return false;
        }

        private static Login loginForm;
        public static Login LoginForm
        {
            get
            {
                if (IsDisposeOrNull(loginForm))
                    loginForm = new Login();
                return InfoControl.loginForm;
            }
            set { InfoControl.loginForm = value; }
        }
        
        private static MainFrame mainForm;
        public static MainFrame MainForm
        {
            get
            {
                if (IsDisposeOrNull(mainForm))
                    mainForm = new MainFrame();
                return InfoControl.mainForm;
            }
            set { InfoControl.mainForm = value; }
        }
        
        private static Register registerForm;
        public static Register RegisterForm
        {
            get
            {
                if (IsDisposeOrNull(registerForm))
                    registerForm = new Register();
                return InfoControl.registerForm;
            }
            set { InfoControl.registerForm = value; }
        }

        //private static SingleChat singleChatForm;
        //public static SingleChat SingleChatForm
        //{
        //    get 
        //    {
        //        if (IsDisposeOrNull(singleChatForm))
        //            singleChatForm = new SingleChat();
        //        return InfoControl.singleChatForm; 
        //    }
        //    set { InfoControl.singleChatForm = value; }
        //}
        
        public static void Initial()
        {
            InterfaceManager.RegisterNetInterface(new NetImplement());
        }
        
        private static List<Image> faceList;
        public static List<Image> FaceList
        {
            get
            {
                if (faceList == null)
                {
                    faceList = new List<Image>();
                    for (int i = 0; i < 40; i++)
                    {
                        faceList.Add((Image)Properties.Resources.ResourceManager.GetObject("f" + (i + 1).ToString()));

                    }
                }
                return InfoControl.faceList;
            }
            set { InfoControl.faceList = value; }
        }
    }
}
